﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;

namespace Auction_Boxing_2
{
    public class StateKnockedDown : State
    {
        const int DownTime = 1500;

        const int Wait = 1;

        GameTimer DownTimer;

        DirectionType Direction;

        float speedReductionValue = .5f;


        public StateKnockedDown(float initialSpeed, DirectionType direction, State state)
        {
            StateName = "dead";
            this.ATextures = state.StatePlayer.ATextures;
            LoadState(state.StatePlayer, ATextures);
            this.Direction = direction;

            speed.X = initialSpeed;

            Debug.WriteLine("Knocked Down!");
        }

        public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures)
        {
            this.StatePlayer = player;
            this.PlayerAnimation = ATextures[StateName];
            StatePlayer.isAttacking = false;
            StatePlayer.isHit = false;

            DownTimer = new GameTimer(Wait, DownTime);

            DownTimer.Start();
        }

        public override void Initialize()
        {

        }

        public override void HandleMovement()
        {


        }

        public override void HandleDirection()
        {
            switch (Direction)
            {

                case DirectionType.Right:
                    speed *= speedReductionValue;
                    Translate(speed.X, 0);
                    break;

                case DirectionType.Left:
                    speed *= speedReductionValue;
                    Translate(speedReductionValue * -speed.X, 0);
                    break;

                default:

                    break;
            }

        }

        public override void Update(GameTime gameTime)
        {

        }

        public override void HandleState()
        {
            if (!DownTimer.Enabled)
                StatePlayer.InternalState = new StateMoving(this);
        }

        public override void Translate(float x, float y)
        {


        }

        public override void HandleCollision(List<BoxingPlayer> Players)
        {

        }


    }
}